//
//  Utility.m
//  3DModelCollector
//
//  Created by Jing Zhang on 7/17/12.
//  Copyright (c) 2012 Tencent. All rights reserved.
//

#import "Utility.h"

@implementation Utility

+ (NSString*)baseAccuracyToString:(BaseAccuracy)accuracy {
    
    switch (accuracy) {
        case BA_Exact:
            return @"很真实";
            
        case BA_Unlike:
            return @"很不像";
            
        case BA_Similar:
            return @"一般";
            
        case BA_Unknown:
            return @"不知道";
            
        default:
            return @"不知道";
    }
}

+ (BaseAccuracy)stringToBaseAccuracy:(NSString *)desc {
    
    if ([desc isEqualToString:@"很真实"]) {
        return BA_Exact;
    }
    else if ([desc isEqualToString:@"很不像"]) {
        return BA_Unlike;
    }
    else if ([desc isEqualToString:@"一般"]) {
        return BA_Similar;
    }
    else {
        return BA_Unknown;
    }
}

+ (NSString*)buildingTypeToString:(BuildingType)type {
    
    switch (type) {
        case BT_House:
            return @"民居";

        case BT_Office:
            return @"写字楼";
            
        case BT_Apartment:
            return @"公寓";
            
        case BT_Mall:
            return @"商场";
            
        case BT_Hotel:
            return @"酒店";
            
        default:
            return @"其它";
    }
}

+ (BuildingType)stringToBuildingType:(NSString *)desc {
    
    if ([desc isEqualToString:@"民居"]) {
        return BT_House;
    }
    else if ([desc isEqualToString:@"写字楼"]) {
        return BT_Office;
    }
    else if ([desc isEqualToString:@"公寓"]) {
        return BT_Apartment;
    }
    else if ([desc isEqualToString:@"商场"]) {
        return BT_Mall;
    }
    else if ([desc isEqualToString:@"酒店"]) {
        return BT_Hotel;
    }
    else if ([desc isEqualToString:@"其它"]) {
        return BT_Other;
    }
    else {
        return BT_Office;
    }
}

+ (NSString*)dateToString:(NSDate *)date {
    
    NSDateFormatter* dateFormatter = [[[NSDateFormatter alloc] init] autorelease];
    [dateFormatter setDateFormat:@"yyyy年MM月dd日"];
    NSString* dateStr = [dateFormatter stringFromDate:date];    

    return dateStr;
}

@end
